package com.minigame.card.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 庄闲家方位
 * 起牌时顺时针: EAST -> SOUTH -> WEST -> NORTH
 * 打牌时逆时针: EAST ->  NORTH -> WEST -> SOUTH
 */
@AllArgsConstructor
@Getter
public enum Direction {
    EAST("东家"), SOUTH("南家"), WEST("西家"), NORTH("北家");
    private final String name;
    private static Direction[] values = values();

    /**
     * 下一个打牌的方位, 逆时针
     */
    public Direction anticlockwiseNext() {
        int ordinal = this.ordinal();
        if (ordinal == 0) {
            return values[values.length - 1];
        }
        return values[ordinal - 1];
    }

    /**
     * 下一个起4张牌的方位, 顺时针
     */
    public Direction clockwiseNext() {
        int ordinal = this.ordinal();
        if (ordinal == values.length - 1) {
            return values[0];
        }
        return values[ordinal + 1];
    }
}
